<html>

<head>
    <title>第一个本地页面</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="./style.css" />
</head>

<body>
    这是第一个本地页面<br />
    它的地址是：
    <script src="./a.js"></script>
    <a href="test.html" target="_blank">打开一个新窗口</a>
    <br />
    <div id="test"></div>
    <img src="../img/web.png" />
    <button onclick="ipc_send()">文件数据流获取测试</button>

    <script>
        function ipc_send() {
            ipcRenderer.send('request-file-stream');
        }

        let result = '';

        function ipc_call_js() {
            const decoder = new TextDecoder('utf-8');
            ipcRenderer.on('file-chunk', (chunk) => {
                console.log("file-chunk ......")
                let decoder = new TextDecoder('utf-8', { ignoreBOM: true })
                    let str = decoder.decode(chunk)
                    result += str;
            });

            ipcRenderer.on('file-end', (param) => {
                console.log("file-end ......")
                // 拼接所有片段并打印
                console.log(result); // 输出拼接后的结果
            });
        }
        ipc_call_js()

    </script>
    </script>

</body>

</html>